﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using NetCoreCMS.IServices;

namespace NetCoreCMS.Web.Areas.WebApi.Controllers.Cart
{
    public class Cart_Goods_ListController : UserController
    {
        public IArticle_goodsService _article_goods { get; set; }
        public IApp_cart_keysService _app_cart_keys { get; set; }
        public IArticleService _article { get; set; }
        public IUser_groupsService _user_groups { get; set; }
        [Authorize]
        [HttpGet]
        public IActionResult Get()
        {
            var user = GetUserInfo();
            if (user == null)
            {
                return Ok(new { status = 0, msg = "请先登录！" });
            }
            ShopCart.AppCartHelper shopcart = new ShopCart.AppCartHelper(_app_cart_keys, _article, _user_groups, _article_goods);
            var goodsList = shopcart.GetList(user.group_id,user.id); //商品列表
            return Ok(new { status = 1, list = goodsList });
        }
    }
}